﻿#include "BaseCmd.h"
#include "../util/JsonUtil.h"

BaseCmd::BaseCmd()
{
}

BaseCmd::~BaseCmd()
{
}

std::string BaseCmd::GetId()
{
	return m_id;
}

void BaseCmd::SetId(std::string v)
{
	m_id = v;
}

std::string BaseCmd::GetBoxId()
{
	return m_boxId;
}

void BaseCmd::SetBoxId(std::string v)
{
	m_boxId = v;
}

int BaseCmd::GetCmd()
{
	return m_cmd;
}

void BaseCmd::SetCmd(int v)
{
	m_cmd = v;
}

bool BaseCmd::Parse(std::string json)
{
	// 解析json
	JsonUtil jsonUtil;
	if (jsonUtil.Parse(json))
	{
		m_id = jsonUtil.GetString("id", "");
		m_boxId = jsonUtil.GetString("boxId", "");
		m_cmd = jsonUtil.GetInt("cmd", -1);
		return true;
	}
	return false;
}